#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>

using namespace std;

typedef pair<int, int> PII;

const int N = 20;

int v[N], w[N];
PII t[N];
int n, m, k;

bool check(int u)
{
	for (int i = 0; i < k; i++)
	{
		int a = t[i].first - 1;
		int b = t[i].second - 1;
		if ((u >> a) & 1 && (u >> b) & 1)
			return false;
	}
	return true;
}

int main()
{
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++)	cin >> v[i] >> w[i];
	for (int i = 0; i < k; i++)	cin >> t[i].first >> t[i].second;
	
	long long res = 0;
	for (int i = 1; i <= (1 << n) - 1; i++)
	{
		if (!check(i))	continue;

		int tmp = i,cur = 0;
		long long tv = 0, tw = 0;
		while (tmp)
		{
			if (tmp & 1)
			{
				tv += v[cur];
				tw += w[cur];
			}
			cur++;
			tmp >>= 1;
		}
		if (tv > m)	continue;
		res = max(res, tw);
	}
	cout << res << endl;
	return 0;
}